package com.run.spring.controller;

import com.run.entity.User;
import com.run.spring.service.UserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @description:
 * @project springboot_demo
 * @author HeWenWen
 * @date 2024-09-13 16:17
 * @version 1.0
 */
@RestController
@RequestMapping("/users")
public class UserController {

    @Autowired
    private UserService userService;

    @Operation(summary = "根据用户ID获取用户", description = "返回指定ID用户的信息")
    @ApiResponse(responseCode = "200", description = "成功获取指定用户ID信息")
    @GetMapping("/{userId}")
    public User getUserById(@PathVariable(value = "userId") int id) {
        return userService.getUserById(id);
    }

}
